package sel.me.spring.boot159.web.extension.event;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;

/**
 * @author shenenlu 2021年03月05日 下午16:36:54
 */
public class EmailListener implements ApplicationListener<ApplicationEvent> {

    public void onApplicationEvent(ApplicationEvent event) {
        if(event instanceof EmailEvent){
            EmailEvent emailEvent = (EmailEvent)event;
            emailEvent.print();
            System.out.println("the source is:" + emailEvent.getSource());
            System.out.println("the address is:" + emailEvent.address);
            System.out.println("the email's context is:" + emailEvent.text);
        }
    }
}
